<?php
/*! \brief
 * This is WFIOFactory class
 * This is the Simple Factory Class that create relative IO Class
 * \author William Su
 */
class WFIOFactory
{
    private $objFramework;
    private static $instance;
    /**
     * @return WFFile
     */
    public function __construct($objFramework){
        $this->objFramework = $objFramework;
    }
    public static function getDirnameFile(){
        if(!isset(self::$instance[__FUNCTION__])){
            self::$instance[__FUNCTION__] = dirname(__FILE__);
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     * @return WFFile
     */
    public function getFile(){
        if(!isset(self::$instance[__CLASS__][__FUNCTION__])){
            require_once(self::getDirnameFile().'/File.php');
            self::$instance[__CLASS__][__FUNCTION__] = new WFFile($this->objFramework);
        }
        return self::$instance[__CLASS__][__FUNCTION__];
    }
    /**
     * @return WFMutex
     */
    public function getMutex($strPathPidFile){
        $key = md5($strPathPidFile);
        if(!isset(self::$instance[__CLASS__][__FUNCTION__][$key])){
            require_once(self::getDirnameFile().'/Mutex.php');
            self::$instance[__CLASS__][__FUNCTION__][$key] = new WFMutex($this->objFramework,$strPathPidFile);
        }
        return self::$instance[__CLASS__][__FUNCTION__][$key];
    }
}